#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define int long long
vector<int> a;
signed main() {
    int n, c;
    int ans = 0;
    unordered_map<int, int> hash;
    cin >> n >> c;
    for(int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if(hash[temp] > 0) {
            hash[temp]++;
        }else {
            hash[temp] = 1;
        }
        a.push_back(temp);
    }
    for(auto s : a) {
        if(hash[s - c] > 0) {
            ans+=hash[s - c];
        }
    }
    cout << ans << endl;
    return 0;
}